pub struct Solution;

impl Solution {
    pub fn count_segments(s: String) -> i32 {
        s
            .lines()
            .into_iter()
            .collect::<String>()
            .split(" ")
            .into_iter()
            .map(|v| v.trim())
            .filter(|&v| !v.is_empty())
            .count() as i32
    }
}